<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>File Source for BuanModelCriteria.php</title>
	<link rel="stylesheet" type="text/css" href="../media/style.css">
	<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
	<td class="header-top-left"><img src="../media/logo.png" border="0" alt="phpDocumentor " /></td>
    <td class="header-top-right">Buan<br /><div class="header-top-right-subpackage"></div></td>
  </tr>
  <tr><td colspan="2" class="header-line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td colspan="2" class="header-menu">
      
                        
                      		[ <a href="../classtrees_Buan.html" class="menu">class tree: Buan</a> ]
		[ <a href="../elementindex_Buan.html" class="menu">index: Buan</a> ]
            [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td colspan="2" class="header-line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="195" class="menu">
		<div class="package-title">Buan</div>
  <div class="package">
	<div id="todolist">
			<p><a href="../todolist.html">Todo List</a></p>
	</div>
	</div>
      <b>Packages:</b><br />
  <div class="package">
              <a href="../li_Buan.html">Buan</a><br />
      	</div>
      <br />
                        <br />
                      </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<h1 align="center">Source for file BuanModelCriteria.php</h1>
<p>Documentation is available at <a href="../Buan/_BuanModelCriteria.php.html">BuanModelCriteria.php</a></p>
<div class="src-code"><span class="php">
<ol><li><div class="src-line"><a name="a1"></a><span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line"><a name="a2"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">*&nbsp;This&nbsp;class&nbsp;provides&nbsp;a&nbsp;means&nbsp;to&nbsp;encapsulate&nbsp;an&nbsp;SQL&nbsp;query&nbsp;within&nbsp;an&nbsp;object.</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc">*</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc">*&nbsp;</span><span class="src-doc-coretag">@package</span><span class="src-doc">&nbsp;Buan</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc">*/</span></div></li>
<li><div class="src-line"><a name="a7"></a>namespace&nbsp;<span class="src-id">Buan</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a8"></a>use&nbsp;\<span class="src-id">StdClass</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a9"></a><span class="src-key">class&nbsp;</span><a href="../Buan/ModelCriteria.html">ModelCriteria</a>&nbsp;<span class="src-key">extends&nbsp;</span><a href="../Buan/Object.html">Object</a>&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a10"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a11"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a12"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@constant-group&nbsp;Operators</span></div></li>
<li><div class="src-line"><a name="a13"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;These&nbsp;constants&nbsp;represent&nbsp;the&nbsp;operators&nbsp;in&nbsp;an&nbsp;equation.</span></div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a15"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constEQUALS">EQUALS</a>&nbsp;=&nbsp;<span class="src-num">1</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a16"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constNOT_EQUALS">NOT_EQUALS</a>&nbsp;=&nbsp;<span class="src-num">2</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a17"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constGREATER_THAN">GREATER_THAN</a>&nbsp;=&nbsp;<span class="src-num">4</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a18"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constGREATER_THAN_OR_EQUAL">GREATER_THAN_OR_EQUAL</a>&nbsp;=&nbsp;<span class="src-num">8</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a19"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constLESS_THAN">LESS_THAN</a>&nbsp;=&nbsp;<span class="src-num">16</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a20"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constLESS_THAN_OR_EQUAL">LESS_THAN_OR_EQUAL</a>&nbsp;=&nbsp;<span class="src-num">32</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a21"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constLIKE">LIKE</a>&nbsp;=&nbsp;<span class="src-num">64</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a22"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constNOT_LIKE">NOT_LIKE</a>&nbsp;=&nbsp;<span class="src-num">128</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a23"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constIS_NULL">IS_NULL</a>&nbsp;=&nbsp;<span class="src-num">256</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a24"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constIS_NOT_NULL">IS_NOT_NULL</a>&nbsp;=&nbsp;<span class="src-num">512</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a25"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constFIND_IN_SET">FIND_IN_SET</a>&nbsp;=&nbsp;<span class="src-num">1024</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a26"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constIN">IN</a>&nbsp;=&nbsp;<span class="src-num">2048</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a27"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a28"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a29"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@constant-group&nbsp;Logic&nbsp;strings</span></div></li>
<li><div class="src-line"><a name="a30"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Logic&nbsp;strings.</span></div></li>
<li><div class="src-line"><a name="a31"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a32"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constLOGIC_OR">LOGIC_OR</a>&nbsp;=&nbsp;<span class="src-str">&quot;OR&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a33"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constLOGIC_AND">LOGIC_AND</a>&nbsp;=&nbsp;<span class="src-str">&quot;AND&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a34"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a35"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a36"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@constant-group&nbsp;Others</span></div></li>
<li><div class="src-line"><a name="a37"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a38"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constWHERE">WHERE</a>&nbsp;=&nbsp;<span class="src-str">&quot;WHERE&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a39"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">const&nbsp;</span><a href="../Buan/ModelCriteria.html#constHAVING">HAVING</a>&nbsp;=&nbsp;<span class="src-str">&quot;HAVING&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a40"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a41"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a42"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@property&nbsp;array&nbsp;$selects</span></div></li>
<li><div class="src-line"><a name="a43"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;List&nbsp;of&nbsp;fields&nbsp;and&nbsp;tables&nbsp;used&nbsp;in&nbsp;the&nbsp;SELECT&nbsp;portion&nbsp;of&nbsp;the&nbsp;query.</span></div></li>
<li><div class="src-line"><a name="a44"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;If&nbsp;neither&nbsp;any&nbsp;fields&nbsp;or&nbsp;any&nbsp;tables&nbsp;exist&nbsp;then&nbsp;SELECT&nbsp;will&nbsp;not&nbsp;be&nbsp;included</span></div></li>
<li><div class="src-line"><a name="a45"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;in&nbsp;the&nbsp;rendered&nbsp;SQL,&nbsp;only&nbsp;the&nbsp;remaining&nbsp;criteria&nbsp;elements.</span></div></li>
<li><div class="src-line"><a name="a46"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a47"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><a href="../Buan/ModelCriteria.html#var$selects">$selects</a>&nbsp;=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">'fields'</span>=&gt;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">,&nbsp;</span><span class="src-str">'tables'</span>=&gt;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a48"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a49"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a50"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@property&nbsp;ModelCriteriaGroup&nbsp;$whereGroup</span></div></li>
<li><div class="src-line"><a name="a51"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;This&nbsp;is&nbsp;the&nbsp;root&nbsp;clause&nbsp;group&nbsp;of&nbsp;which&nbsp;all&nbsp;other&nbsp;clause&nbsp;groups&nbsp;are</span></div></li>
<li><div class="src-line"><a name="a52"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;children.</span></div></li>
<li><div class="src-line"><a name="a53"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a54"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><a href="../Buan/ModelCriteria.html#var$whereGroup">$whereGroup</a>&nbsp;=&nbsp;<span class="src-id">NULL</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a55"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a56"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a57"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@property&nbsp;array&nbsp;$leftJoins</span></div></li>
<li><div class="src-line"><a name="a58"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Holds&nbsp;all&nbsp;LEFT&nbsp;JOINs.&nbsp;The&nbsp;order&nbsp;they&nbsp;appear&nbsp;in&nbsp;this&nbsp;array&nbsp;is&nbsp;the&nbsp;order</span></div></li>
<li><div class="src-line"><a name="a59"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;in&nbsp;which&nbsp;they&nbsp;are&nbsp;added&nbsp;to&nbsp;the&nbsp;generated&nbsp;SQL&nbsp;query.</span></div></li>
<li><div class="src-line"><a name="a60"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a61"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Format:</span></div></li>
<li><div class="src-line"><a name="a62"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;$leftJoins&nbsp;=&nbsp;array(</span></div></li>
<li><div class="src-line"><a name="a63"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(</span></div></li>
<li><div class="src-line"><a name="a64"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'table'=&gt;[table&nbsp;name],</span></div></li>
<li><div class="src-line"><a name="a65"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'clause'=&gt;[joining&nbsp;clause&nbsp;(ie.&nbsp;part&nbsp;used&nbsp;in&nbsp;&quot;...&nbsp;ON&nbsp;...&quot;)]</span></div></li>
<li><div class="src-line"><a name="a66"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),</span></div></li>
<li><div class="src-line"><a name="a67"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...</span></div></li>
<li><div class="src-line"><a name="a68"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;);</span></div></li>
<li><div class="src-line"><a name="a69"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a70"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><a href="../Buan/ModelCriteria.html#var$leftJoins">$leftJoins</a>&nbsp;=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a71"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a72"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a73"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@property&nbsp;array&nbsp;$groupBys</span></div></li>
<li><div class="src-line"><a name="a74"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;List&nbsp;of&nbsp;fields&nbsp;that&nbsp;will&nbsp;be&nbsp;added&nbsp;to&nbsp;a&nbsp;GROUP&nbsp;BY&nbsp;clause.</span></div></li>
<li><div class="src-line"><a name="a75"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a76"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Format:</span></div></li>
<li><div class="src-line"><a name="a77"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;$groupBys&nbsp;=&nbsp;array('[field-name]',&nbsp;...);</span></div></li>
<li><div class="src-line"><a name="a78"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a79"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><a href="../Buan/ModelCriteria.html#var$groupBys">$groupBys</a>&nbsp;=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a80"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a81"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a82"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@property&nbsp;array&nbsp;$havingGroup</span></div></li>
<li><div class="src-line"><a name="a83"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;A&nbsp;ModelCriteriGroup&nbsp;object&nbsp;that&nbsp;contains&nbsp;sub-groups&nbsp;that&nbsp;will&nbsp;be&nbsp;rendered</span></div></li>
<li><div class="src-line"><a name="a84"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;in&nbsp;the&nbsp;HAVING&nbsp;portion&nbsp;of&nbsp;the&nbsp;query,&nbsp;rather&nbsp;than&nbsp;the&nbsp;WHERE&nbsp;portion.</span></div></li>
<li><div class="src-line"><a name="a85"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a86"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><a href="../Buan/ModelCriteria.html#var$havingGroup">$havingGroup</a>&nbsp;=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a87"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a88"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a89"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@property&nbsp;array&nbsp;$orders</span></div></li>
<li><div class="src-line"><a name="a90"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Holds&nbsp;any&nbsp;ORDER&nbsp;clauses.&nbsp;The&nbsp;order&nbsp;they&nbsp;appear&nbsp;in&nbsp;this&nbsp;array&nbsp;is&nbsp;the&nbsp;order</span></div></li>
<li><div class="src-line"><a name="a91"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;in&nbsp;which&nbsp;they&nbsp;are&nbsp;added&nbsp;to&nbsp;the&nbsp;generated&nbsp;SQL&nbsp;query.</span></div></li>
<li><div class="src-line"><a name="a92"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a93"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Format:</span></div></li>
<li><div class="src-line"><a name="a94"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;$orders&nbsp;=&nbsp;array(</span></div></li>
<li><div class="src-line"><a name="a95"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(</span></div></li>
<li><div class="src-line"><a name="a96"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'fieldName'=&gt;[ordering&nbsp;field],</span></div></li>
<li><div class="src-line"><a name="a97"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'direction'=&gt;[order&nbsp;direction&nbsp;(ASC&nbsp;|&nbsp;DESC)]</span></div></li>
<li><div class="src-line"><a name="a98"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),</span></div></li>
<li><div class="src-line"><a name="a99"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...</span></div></li>
<li><div class="src-line"><a name="a100"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;);</span></div></li>
<li><div class="src-line"><a name="a101"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a102"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><a href="../Buan/ModelCriteria.html#var$orders">$orders</a>&nbsp;=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a103"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a104"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a105"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@property&nbsp;array&nbsp;$limit</span></div></li>
<li><div class="src-line"><a name="a106"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Holds&nbsp;the&nbsp;LIMIT&nbsp;clause&nbsp;criteria.</span></div></li>
<li><div class="src-line"><a name="a107"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a108"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Format:</span></div></li>
<li><div class="src-line"><a name="a109"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;$limit&nbsp;=&nbsp;array(</span></div></li>
<li><div class="src-line"><a name="a110"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'start'=&gt;[record&nbsp;number&nbsp;to&nbsp;start&nbsp;the&nbsp;limited&nbsp;range&nbsp;from],</span></div></li>
<li><div class="src-line"><a name="a111"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'recordCount'=&gt;[max&nbsp;number&nbsp;of&nbsp;records&nbsp;to&nbsp;return]</span></div></li>
<li><div class="src-line"><a name="a112"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;);</span></div></li>
<li><div class="src-line"><a name="a113"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a114"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><a href="../Buan/ModelCriteria.html#var$limit">$limit</a>&nbsp;=&nbsp;<span class="src-id">NULL</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a115"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a116"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a117"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;__construct()</span></div></li>
<li><div class="src-line"><a name="a118"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a119"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#method__construct">__construct</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a120"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a121"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Create&nbsp;the&nbsp;root&nbsp;clause&nbsp;group</span></div></li>
<li><div class="src-line"><a name="a122"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$whereGroup">whereGroup</a>&nbsp;=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../Buan/ModelCriteriaGroup.html">ModelCriteriaGroup</a></span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a123"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$havingGroup">havingGroup</a>&nbsp;=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id"><a href="../Buan/ModelCriteriaGroup.html">ModelCriteriaGroup</a></span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a124"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a125"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a126"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a127"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;ModelCriteriaGroup&nbsp;addGroup(&nbsp;[string&nbsp;$logic]&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a128"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$logic&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Evaluation&nbsp;logic&nbsp;used&nbsp;to&nbsp;join&nbsp;clauses&nbsp;in&nbsp;this&nbsp;new&nbsp;group</span></div></li>
<li><div class="src-line"><a name="a129"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a130"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Generate&nbsp;and&nbsp;return&nbsp;a&nbsp;clause&nbsp;group.</span></div></li>
<li><div class="src-line"><a name="a131"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a132"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodaddGroup">addGroup</a><span class="src-sym">(</span><span class="src-var">$logic</span>=<span class="src-id">ModelCriteria</span><span class="src-sym">::</span><span class="src-id">LOGIC_AND</span><span class="src-sym">,&nbsp;</span><span class="src-var">$type</span>=<span class="src-id">ModelCriteria</span><span class="src-sym">::</span><span class="src-id">WHERE</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a133"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a134"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Generate&nbsp;and&nbsp;return</span></div></li>
<li><div class="src-line"><a name="a135"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$type</span>==<span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">WHERE&nbsp;</span>?&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$whereGroup">whereGroup</a><span class="src-sym">-&gt;</span><span class="src-id">addGroup</span><span class="src-sym">(</span><span class="src-var">$logic</span><span class="src-sym">)&nbsp;</span>:&nbsp;<span class="src-sym">(</span><span class="src-var">$type</span>==<span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">HAVING&nbsp;</span>?&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$havingGroup">havingGroup</a><span class="src-sym">-&gt;</span><span class="src-id">addGroup</span><span class="src-sym">(</span><span class="src-var">$logic</span><span class="src-sym">)&nbsp;</span>:&nbsp;<span class="src-id">NULL</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a136"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a137"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a138"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a139"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;selectField(&nbsp;string|ModelCriteria&nbsp;$field,&nbsp;[string&nbsp;$alias]&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a140"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$field&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Field&nbsp;(eg.&nbsp;&quot;id&quot;,&nbsp;&quot;*&quot;,&nbsp;&quot;COUNT(*)&nbsp;AS&nbsp;c&quot;,&nbsp;etc)&nbsp;or&nbsp;subquery</span></div></li>
<li><div class="src-line"><a name="a141"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$alias&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Field&nbsp;alias</span></div></li>
<li><div class="src-line"><a name="a142"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a143"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Add&nbsp;a&nbsp;field&nbsp;to&nbsp;the&nbsp;SELECT&nbsp;portion&nbsp;of&nbsp;the&nbsp;query.</span></div></li>
<li><div class="src-line"><a name="a144"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;If&nbsp;JOINing&nbsp;multiple&nbsp;tables&nbsp;in&nbsp;this&nbsp;query,&nbsp;then&nbsp;it's&nbsp;a&nbsp;good&nbsp;idea&nbsp;to&nbsp;prefix</span></div></li>
<li><div class="src-line"><a name="a145"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;the&nbsp;field&nbsp;with&nbsp;a&nbsp;table&nbsp;name.</span></div></li>
<li><div class="src-line"><a name="a146"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;You&nbsp;can&nbsp;actual&nbsp;insert&nbsp;a&nbsp;subquery&nbsp;by&nbsp;specifying&nbsp;$field&nbsp;as&nbsp;a&nbsp;ModelCriteria</span></div></li>
<li><div class="src-line"><a name="a147"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;object.</span></div></li>
<li><div class="src-line"><a name="a148"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a149"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodselectField">selectField</a><span class="src-sym">(</span><span class="src-var">$field</span><span class="src-sym">,&nbsp;</span><span class="src-var">$alias</span>=<span class="src-id">NULL</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a150"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$fObj&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id">StdClass</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a151"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$fObj</span><span class="src-sym">-&gt;</span><span class="src-id">alias&nbsp;</span>=&nbsp;<span class="src-var">$alias</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a152"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$field&nbsp;</span>instanceof&nbsp;<span class="src-id"><a href="../Buan/ModelCriteria.html">ModelCriteria</a></span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a153"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql&nbsp;</span>=&nbsp;<span class="src-var">$field</span><span class="src-sym">-&gt;</span><span class="src-id">sql</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a154"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$fObj</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>=&nbsp;<span class="src-str">&quot;</span><span class="src-str">({<span class="src-var">$sql</span></span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-str"></span><span class="src-sym">}</span>)</span><span class="src-str">&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a155"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$fObj</span><span class="src-sym">-&gt;</span><span class="src-id">bindings&nbsp;</span>=&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a156"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a157"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a158"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$fObj</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>=&nbsp;<span class="src-var">$field</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a159"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$fObj</span><span class="src-sym">-&gt;</span><span class="src-id">bindings&nbsp;</span>=&nbsp;<span class="src-id">NULL</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a160"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}&nbsp;</span></div></li>
<li><div class="src-line"><a name="a161"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$selects">selects</a><span class="src-sym">[</span><span class="src-str">'fields'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$fObj</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a162"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a163"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a164"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a165"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;bool&nbsp;hasSelectFields()</span></div></li>
<li><div class="src-line"><a name="a166"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a167"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Returns&nbsp;TRUE&nbsp;if&nbsp;any&nbsp;SELECT&nbsp;fields&nbsp;have&nbsp;been&nbsp;defined.</span></div></li>
<li><div class="src-line"><a name="a168"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a169"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodhasSelectFields">hasSelectFields</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a170"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$selects">selects</a><span class="src-sym">[</span><span class="src-str">'fields'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;</span>?&nbsp;<span class="src-id">FALSE&nbsp;</span>:&nbsp;<span class="src-id">TRUE</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a171"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a172"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a173"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a174"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;selectTable(&nbsp;string&nbsp;$table&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a175"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$table&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Table&nbsp;name</span></div></li>
<li><div class="src-line"><a name="a176"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a177"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Add&nbsp;a&nbsp;table&nbsp;to&nbsp;the&nbsp;FROM&nbsp;portion&nbsp;of&nbsp;the&nbsp;query.</span></div></li>
<li><div class="src-line"><a name="a178"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Duplicates&nbsp;will&nbsp;be&nbsp;ignored.</span></div></li>
<li><div class="src-line"><a name="a179"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a180"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodselectTable">selectTable</a><span class="src-sym">(</span><span class="src-var">$table</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a181"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a182"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Wrap&nbsp;a&nbsp;simple&nbsp;table&nbsp;name&nbsp;in&nbsp;`&nbsp;marks.</span></div></li>
<li><div class="src-line"><a name="a183"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;As&nbsp;$table&nbsp;can&nbsp;be,&nbsp;for&nbsp;example,&nbsp;&quot;tablename&nbsp;AS&nbsp;tb&quot;,&nbsp;then&nbsp;we&nbsp;need&nbsp;to</span></div></li>
<li><div class="src-line"><a name="a184"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;ignore&nbsp;such&nbsp;cases&nbsp;and&nbsp;put&nbsp;to&nbsp;onus&nbsp;onto&nbsp;the&nbsp;user.</span></div></li>
<li><div class="src-line"><a name="a185"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/preg_match">preg_match</a><span class="src-sym">(</span><span class="src-str">&quot;/[^0-9a-z_]/i&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$table</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a186"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$table&nbsp;</span>=&nbsp;<a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$table</span><span class="src-sym">,&nbsp;</span><span class="src-num">0</span><span class="src-sym">,&nbsp;</span><span class="src-num">1</span><span class="src-sym">)</span>!=<span class="src-str">&quot;`&quot;&nbsp;</span>?&nbsp;<span class="src-str">&quot;</span><span class="src-str">`{<span class="src-var">$table</span><span class="src-sym">}</span>`</span><span class="src-str">&quot;&nbsp;</span>:&nbsp;<span class="src-var">$table</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a187"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a188"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a189"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;to&nbsp;list,&nbsp;ensuring&nbsp;duplicates&nbsp;aren't&nbsp;added</span></div></li>
<li><div class="src-line"><a name="a190"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/in_array">in_array</a><span class="src-sym">(</span><span class="src-var">$table</span><span class="src-sym">,&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$selects">selects</a><span class="src-sym">[</span><span class="src-str">'tables'</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a191"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$selects">selects</a><span class="src-sym">[</span><span class="src-str">'tables'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$table</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a192"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a193"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a194"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a195"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a196"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;addClause(&nbsp;int&nbsp;$clause,&nbsp;string&nbsp;$fieldName,&nbsp;[mixed&nbsp;$fieldValue,&nbsp;[bool&nbsp;$valueIsReference]]&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a197"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$clause&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Logic&nbsp;clause&nbsp;(see&nbsp;'clause&nbsp;constants'&nbsp;above)</span></div></li>
<li><div class="src-line"><a name="a198"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$fieldName&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Field&nbsp;name</span></div></li>
<li><div class="src-line"><a name="a199"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$fieldValue&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Field&nbsp;value</span></div></li>
<li><div class="src-line"><a name="a200"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$valueIsReference&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;If&nbsp;TRUE&nbsp;then&nbsp;$fieldValue&nbsp;is&nbsp;assumed&nbsp;to&nbsp;be&nbsp;a&nbsp;column&nbsp;reference&nbsp;rather&nbsp;than&nbsp;a&nbsp;literal&nbsp;value</span></div></li>
<li><div class="src-line"><a name="a201"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a202"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Add&nbsp;a&nbsp;clause&nbsp;to&nbsp;the&nbsp;WHERE&nbsp;portion&nbsp;of&nbsp;the&nbsp;query.</span></div></li>
<li><div class="src-line"><a name="a203"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a204"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodaddClause">addClause</a><span class="src-sym">(</span><span class="src-var">$clause</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fieldName</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fieldValue</span>=<span class="src-id">NULL</span><span class="src-sym">,&nbsp;</span><span class="src-var">$valueIsReference</span>=<span class="src-id">FALSE</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a205"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a206"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;the&nbsp;clause&nbsp;to&nbsp;the&nbsp;root&nbsp;clause&nbsp;group</span></div></li>
<li><div class="src-line"><a name="a207"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/func_num_args">func_num_args</a><span class="src-sym">(</span><span class="src-sym">)</span>&lt;<span class="src-num">3</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a208"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$whereGroup">whereGroup</a><span class="src-sym">-&gt;</span><span class="src-id">addClause</span><span class="src-sym">(</span><span class="src-var">$clause</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fieldName</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a209"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a210"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a211"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$whereGroup">whereGroup</a><span class="src-sym">-&gt;</span><span class="src-id">addClause</span><span class="src-sym">(</span><span class="src-var">$clause</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fieldName</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fieldValue</span><span class="src-sym">,&nbsp;</span><span class="src-var">$valueIsReference</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a212"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a213"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a214"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a215"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a216"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;public&nbsp;addClauseLiteral(&nbsp;string&nbsp;$clause&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a217"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$clause&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Literal&nbsp;clause</span></div></li>
<li><div class="src-line"><a name="a218"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a219"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Sometimes&nbsp;you&nbsp;need&nbsp;to&nbsp;add&nbsp;clauses&nbsp;that&nbsp;refer&nbsp;to&nbsp;column&nbsp;identifiers,&nbsp;such</span></div></li>
<li><div class="src-line"><a name="a220"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;as&nbsp;&quot;WHERE&nbsp;table1.id=table2.other_id&nbsp;...&quot;.&nbsp;This&nbsp;method&nbsp;allows&nbsp;you&nbsp;to&nbsp;define</span></div></li>
<li><div class="src-line"><a name="a221"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;such&nbsp;clauses.</span></div></li>
<li><div class="src-line"><a name="a222"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a223"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodaddClauseLiteral">addClauseLiteral</a><span class="src-sym">(</span><span class="src-var">$clause</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a224"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$whereGroup">whereGroup</a><span class="src-sym">-&gt;</span><span class="src-id">addClauseLiteral</span><span class="src-sym">(</span><span class="src-var">$clause</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a225"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a226"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a227"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a228"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;addHavingClause(&nbsp;int&nbsp;$clause,&nbsp;string&nbsp;$fieldName,&nbsp;mixed&nbsp;$fieldValue,&nbsp;[bool&nbsp;$valueIsReference]&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a229"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$clause&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Logic&nbsp;clause&nbsp;(see&nbsp;'clause&nbsp;constants'&nbsp;above)</span></div></li>
<li><div class="src-line"><a name="a230"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$fieldName&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Field&nbsp;name</span></div></li>
<li><div class="src-line"><a name="a231"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$fieldValue&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Field&nbsp;value</span></div></li>
<li><div class="src-line"><a name="a232"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$valueIsReference&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;If&nbsp;TRUE&nbsp;then&nbsp;$fieldValue&nbsp;is&nbsp;assumed&nbsp;to&nbsp;be&nbsp;a&nbsp;column&nbsp;reference&nbsp;rather&nbsp;than&nbsp;a&nbsp;literal&nbsp;value</span></div></li>
<li><div class="src-line"><a name="a233"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a234"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Add&nbsp;a&nbsp;clause&nbsp;to&nbsp;the&nbsp;HAVING&nbsp;portion&nbsp;of&nbsp;the&nbsp;query.</span></div></li>
<li><div class="src-line"><a name="a235"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a236"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodaddHavingClause">addHavingClause</a><span class="src-sym">(</span><span class="src-var">$clause</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fieldName</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fieldValue</span><span class="src-sym">,&nbsp;</span><span class="src-var">$valueIsReference</span>=<span class="src-id">FALSE</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a237"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$havingGroup">havingGroup</a><span class="src-sym">-&gt;</span><span class="src-id">addClause</span><span class="src-sym">(</span><span class="src-var">$clause</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fieldName</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fieldValue</span><span class="src-sym">,&nbsp;</span><span class="src-var">$valueIsReference</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a238"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a239"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a240"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a241"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;setRange(&nbsp;int&nbsp;$start,&nbsp;int&nbsp;$recordCount&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a242"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Record&nbsp;at&nbsp;which&nbsp;to&nbsp;start&nbsp;the&nbsp;returned&nbsp;range</span></div></li>
<li><div class="src-line"><a name="a243"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$recordCount&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Number&nbsp;of&nbsp;records&nbsp;to&nbsp;return</span></div></li>
<li><div class="src-line"><a name="a244"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a245"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Sets&nbsp;the&nbsp;limiting&nbsp;clause.&nbsp;Omit&nbsp;both&nbsp;arguments&nbsp;to&nbsp;clear&nbsp;an&nbsp;existing&nbsp;range.</span></div></li>
<li><div class="src-line"><a name="a246"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a247"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodsetRange">setRange</a><span class="src-sym">(</span><span class="src-var">$start</span>=<span class="src-id">NULL</span><span class="src-sym">,&nbsp;</span><span class="src-var">$recordCount</span>=<span class="src-id">NULL</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a248"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$start</span>===<span class="src-id">NULL&nbsp;</span>&amp;&amp;&nbsp;<span class="src-var">$recordCount</span>===<span class="src-id">NULL</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a249"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$limit">limit</a>&nbsp;=&nbsp;<span class="src-id">NULL</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a250"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a251"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a252"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$limit">limit</a>&nbsp;=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span></div></li>
<li><div class="src-line"><a name="a253"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'start'</span>=&gt;<span class="src-var">$start</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a254"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'recordCount'</span>=&gt;<span class="src-var">$recordCount</span>-<span class="src-var">$start</span></div></li>
<li><div class="src-line"><a name="a255"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a256"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a257"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a258"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a259"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a260"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;addOrder(&nbsp;string&nbsp;$fieldName,&nbsp;[string&nbsp;$direction]&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a261"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$fieldName&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Field&nbsp;name</span></div></li>
<li><div class="src-line"><a name="a262"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$direction&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;Ordering&nbsp;direction&nbsp;(ASC&nbsp;or&nbsp;DESC)</span></div></li>
<li><div class="src-line"><a name="a263"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a264"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Adds&nbsp;an&nbsp;ordering&nbsp;clause.</span></div></li>
<li><div class="src-line"><a name="a265"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a266"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodaddOrder">addOrder</a><span class="src-sym">(</span><span class="src-var">$fieldName</span><span class="src-sym">,&nbsp;</span><span class="src-var">$direction</span>=<span class="src-str">'ASC'</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a267"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$orders">orders</a><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span></div></li>
<li><div class="src-line"><a name="a268"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'fieldName'</span>=&gt;<span class="src-var">$fieldName</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a269"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'direction'</span>=&gt;<span class="src-var">$direction</span></div></li>
<li><div class="src-line"><a name="a270"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a271"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a272"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a273"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a274"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;leftJoin(&nbsp;string&nbsp;$table,&nbsp;string&nbsp;$clause&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a275"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$table&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Table&nbsp;name</span></div></li>
<li><div class="src-line"><a name="a276"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$clause&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Joining&nbsp;clause&nbsp;(eg.&nbsp;&quot;person.job_id=job.id&quot;</span></div></li>
<li><div class="src-line"><a name="a277"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a278"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;LEFT&nbsp;JOIN&nbsp;the&nbsp;specified&nbsp;table.</span></div></li>
<li><div class="src-line"><a name="a279"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a280"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodleftJoin">leftJoin</a><span class="src-sym">(</span><span class="src-var">$table</span><span class="src-sym">,&nbsp;</span><span class="src-var">$clause</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a281"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$leftJoins">leftJoins</a><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span></div></li>
<li><div class="src-line"><a name="a282"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'table'</span>=&gt;<span class="src-var">$table</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a283"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'clause'</span>=&gt;<span class="src-var">$clause</span></div></li>
<li><div class="src-line"><a name="a284"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a285"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a286"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a287"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a288"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;innerJoin(&nbsp;string&nbsp;$table,&nbsp;string&nbsp;$clause&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a289"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$table&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Table&nbsp;name</span></div></li>
<li><div class="src-line"><a name="a290"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$clause&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Joining&nbsp;clause&nbsp;(will&nbsp;be&nbsp;added&nbsp;to&nbsp;the&nbsp;WHERE&nbsp;portion)</span></div></li>
<li><div class="src-line"><a name="a291"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a292"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Adds&nbsp;necessary&nbsp;elements&nbsp;to&nbsp;join&nbsp;the&nbsp;specified&nbsp;table.</span></div></li>
<li><div class="src-line"><a name="a293"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$clause&nbsp;is&nbsp;a&nbsp;literal&nbsp;string,&nbsp;meaning&nbsp;it&nbsp;will&nbsp;be&nbsp;added&nbsp;to&nbsp;the&nbsp;SQL&nbsp;exactly</span></div></li>
<li><div class="src-line"><a name="a294"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;as&nbsp;provided&nbsp;here.</span></div></li>
<li><div class="src-line"><a name="a295"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a296"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodinnerJoin">innerJoin</a><span class="src-sym">(</span><span class="src-var">$table</span><span class="src-sym">,&nbsp;</span><span class="src-var">$clause</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a297"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#methodselectTable">selectTable</a><span class="src-sym">(</span><span class="src-var">$table</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a298"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#methodaddClauseLiteral">addClauseLiteral</a><span class="src-sym">(</span><span class="src-var">$clause</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a299"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a300"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a301"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a302"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;groupBy(&nbsp;string&nbsp;$field&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a303"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$field&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Field&nbsp;name&nbsp;(eg.&nbsp;&quot;age&quot;&nbsp;or&nbsp;&quot;table_name.age&quot;</span></div></li>
<li><div class="src-line"><a name="a304"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a305"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Adds&nbsp;a&nbsp;GROUP&nbsp;BY&nbsp;clause.</span></div></li>
<li><div class="src-line"><a name="a306"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a307"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodgroupBy">groupBy</a><span class="src-sym">(</span><span class="src-var">$field</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a308"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$groupBys">groupBys</a><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$field</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a309"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a310"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a311"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a312"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;ungroupBy(&nbsp;[string&nbsp;$field]&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a313"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;$field&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Field&nbsp;name&nbsp;(eg.&nbsp;&quot;age&quot;&nbsp;or&nbsp;&quot;table_name.age&quot;</span></div></li>
<li><div class="src-line"><a name="a314"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a315"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Removes&nbsp;a&nbsp;GROUP&nbsp;BY&nbsp;clause,&nbsp;or&nbsp;if&nbsp;$field&nbsp;is&nbsp;not&nbsp;omitted&nbsp;then&nbsp;all&nbsp;GROUP&nbsp;BY</span></div></li>
<li><div class="src-line"><a name="a316"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;clauses&nbsp;are&nbsp;removed.</span></div></li>
<li><div class="src-line"><a name="a317"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a318"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodungroupBy">ungroupBy</a><span class="src-sym">(</span><span class="src-var">$field</span>=<span class="src-id">NULL</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a319"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$field</span>===<span class="src-id">NULL</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a320"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$groupBys">groupBys</a>&nbsp;=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a321"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a322"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">else&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a323"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$groupBys">groupBys</a>&nbsp;=&nbsp;<a href="http://www.php.net/array_diff">array_diff</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$groupBys">groupBys</a><span class="src-sym">,&nbsp;</span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$field</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a324"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a325"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a326"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a327"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a328"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;string&nbsp;sql()</span></div></li>
<li><div class="src-line"><a name="a329"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a330"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Generates&nbsp;and&nbsp;returns&nbsp;an&nbsp;object&nbsp;containing&nbsp;and&nbsp;SQL&nbsp;query&nbsp;and&nbsp;any&nbsp;variable</span></div></li>
<li><div class="src-line"><a name="a331"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;bindings:</span></div></li>
<li><div class="src-line"><a name="a332"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;{</span></div></li>
<li><div class="src-line"><a name="a333"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;query:&nbsp;'actual&nbsp;query',</span></div></li>
<li><div class="src-line"><a name="a334"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bindings:&nbsp;array(</span></div></li>
<li><div class="src-line"><a name="a335"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'param-name':&nbsp;'param-value',</span></div></li>
<li><div class="src-line"><a name="a336"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...</span></div></li>
<li><div class="src-line"><a name="a337"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</span></div></li>
<li><div class="src-line"><a name="a338"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;}</span></div></li>
<li><div class="src-line"><a name="a339"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a340"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#methodsql">sql</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a341"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a342"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Vars</span></div></li>
<li><div class="src-line"><a name="a343"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql&nbsp;</span>=&nbsp;<span class="src-key">new&nbsp;</span><span class="src-id">StdClass</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a344"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>=&nbsp;<span class="src-str">''</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a345"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a346"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a347"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Generate&nbsp;WHERE&nbsp;portion&nbsp;from&nbsp;the&nbsp;root&nbsp;clause&nbsp;group&nbsp;and&nbsp;all&nbsp;sub-groups</span></div></li>
<li><div class="src-line"><a name="a348"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$whereSql&nbsp;</span>=&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$whereGroup">whereGroup</a><span class="src-sym">-&gt;</span><span class="src-id">sql</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a349"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$whereSql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>=&nbsp;<a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;()&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$whereSql</span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a350"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$whereSql</span><span class="src-sym">-&gt;</span><span class="src-id">query</span>!=<span class="src-str">''</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a351"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$whereSql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>=&nbsp;<a href="http://www.php.net/preg_replace">preg_replace</a><span class="src-sym">(</span><span class="src-str">&quot;/\((.*)\)$/&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;$1&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$whereSql</span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a352"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>=&nbsp;<span class="src-str">&quot;</span><span class="src-str">&nbsp;WHERE&nbsp;{<span class="src-var">$whereSql</span></span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-str"></span><span class="src-sym">}</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a353"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings&nbsp;</span>=&nbsp;<a href="http://www.php.net/array_merge">array_merge</a><span class="src-sym">(</span><span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings</span><span class="src-sym">,&nbsp;</span><span class="src-var">$whereSql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a354"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a355"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a356"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;GROUP&nbsp;BYs</span></div></li>
<li><div class="src-line"><a name="a357"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$groupBys">groupBys</a><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a358"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>.=&nbsp;<span class="src-str">'&nbsp;GROUP&nbsp;BY&nbsp;'</span>.<a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;,&nbsp;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$groupBys">groupBys</a><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a359"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a360"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a361"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;HAVING&nbsp;clauses</span></div></li>
<li><div class="src-line"><a name="a362"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$havingSql&nbsp;</span>=&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$havingGroup">havingGroup</a><span class="src-sym">-&gt;</span><span class="src-id">sql</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a363"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$havingSql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>=&nbsp;<a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;()&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-str">&quot;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$havingSql</span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a364"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$havingSql</span><span class="src-sym">-&gt;</span><span class="src-id">query</span>!=<span class="src-str">''</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a365"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>.=&nbsp;<span class="src-str">&quot;</span><span class="src-str">&nbsp;HAVING&nbsp;{<span class="src-var">$havingSql</span></span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-str"></span><span class="src-sym">}</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a366"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings&nbsp;</span>=&nbsp;<a href="http://www.php.net/array_merge">array_merge</a><span class="src-sym">(</span><span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings</span><span class="src-sym">,&nbsp;</span><span class="src-var">$havingSql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a367"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a368"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a369"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;ORDER&nbsp;BYs</span></div></li>
<li><div class="src-line"><a name="a370"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$orders">orders</a><span class="src-sym">)</span>&gt;<span class="src-num">0</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a371"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>.=&nbsp;<span class="src-str">'&nbsp;ORDER&nbsp;BY&nbsp;'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a372"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$orders&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a373"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">foreach</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$orders">orders</a>&nbsp;<span class="src-key">as&nbsp;</span><span class="src-var">$order</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a374"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$orders</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-var">$order</span><span class="src-sym">[</span><span class="src-str">'fieldName'</span><span class="src-sym">]</span>.<span class="src-str">'&nbsp;'</span>.<span class="src-var">$order</span><span class="src-sym">[</span><span class="src-str">'direction'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a375"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a376"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>.=&nbsp;<a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;,&nbsp;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$orders</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a377"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a378"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a379"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;LIMIT</span></div></li>
<li><div class="src-line"><a name="a380"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_null">is_null</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$limit">limit</a><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a381"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>.=&nbsp;<span class="src-str">'&nbsp;LIMIT&nbsp;'</span>.<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$limit">limit</a><span class="src-sym">[</span><span class="src-str">'recordCount'</span><span class="src-sym">]</span>.<span class="src-str">'&nbsp;OFFSET&nbsp;'</span>.<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$limit">limit</a><span class="src-sym">[</span><span class="src-str">'start'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a382"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a383"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a384"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;LEFT&nbsp;JOINs</span></div></li>
<li><div class="src-line"><a name="a385"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$leftJoins">leftJoins</a><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a386"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$joins&nbsp;</span>=&nbsp;<a href="http://www.php.net/array_reverse">array_reverse</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$leftJoins">leftJoins</a><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a387"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">foreach</span><span class="src-sym">(</span><span class="src-var">$joins&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$join</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a388"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>=&nbsp;<span class="src-str">'&nbsp;LEFT&nbsp;JOIN&nbsp;'</span>.<span class="src-var">$join</span><span class="src-sym">[</span><span class="src-str">'table'</span><span class="src-sym">]</span>.<span class="src-str">'&nbsp;ON&nbsp;'</span>.<span class="src-var">$join</span><span class="src-sym">[</span><span class="src-str">'clause'</span><span class="src-sym">]</span>.<span class="src-str">'&nbsp;'</span>.<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a389"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a390"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a391"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a392"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;SELECT&nbsp;fields</span></div></li>
<li><div class="src-line"><a name="a393"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$selects">selects</a><span class="src-sym">[</span><span class="src-str">'fields'</span><span class="src-sym">]</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a394"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$fields&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a395"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">foreach</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$selects">selects</a><span class="src-sym">[</span><span class="src-str">'fields'</span><span class="src-sym">]&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$field</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a396"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$fields</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-str">&quot;</span>{<span class="src-var">$field</span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-str"></span><span class="src-sym">}</span>&nbsp;</span><span class="src-str">&quot;</span>.<span class="src-sym">(</span><span class="src-var">$field</span><span class="src-sym">-&gt;</span><span class="src-id">alias</span>===<span class="src-id">NULL&nbsp;</span>?&nbsp;<span class="src-str">''&nbsp;</span>:&nbsp;<span class="src-str">&quot;</span><span class="src-str">&nbsp;AS&nbsp;{<span class="src-var">$field</span></span><span class="src-sym">-&gt;</span><span class="src-id">alias</span><span class="src-str"></span><span class="src-sym">}</span></span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a397"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$field</span><span class="src-sym">-&gt;</span><span class="src-id">bindings</span>!==<span class="src-id">NULL</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a398"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings&nbsp;</span>=&nbsp;<a href="http://www.php.net/array_merge">array_merge</a><span class="src-sym">(</span><span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">bindings</span><span class="src-sym">,&nbsp;</span><span class="src-var">$field</span><span class="src-sym">-&gt;</span><span class="src-id">bindings</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a399"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a400"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a401"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query&nbsp;</span>=&nbsp;<span class="src-str">'SELECT&nbsp;'</span>.<a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;,&nbsp;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$fields</span><span class="src-sym">)</span>.<span class="src-str">'&nbsp;'</span>.<span class="src-sym">(</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$selects">selects</a><span class="src-sym">[</span><span class="src-str">'tables'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;</span>?&nbsp;<span class="src-str">'FROM&nbsp;'</span>.<a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;,&nbsp;&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$selects">selects</a><span class="src-sym">[</span><span class="src-str">'tables'</span><span class="src-sym">]</span><span class="src-sym">)</span>.<span class="src-str">'&nbsp;'&nbsp;</span>:&nbsp;<span class="src-str">''</span><span class="src-sym">)</span>.<span class="src-var">$sql</span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a402"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a403"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a404"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;Result</span></div></li>
<li><div class="src-line"><a name="a405"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$sql</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a406"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a407"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a408"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a409"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;@method&nbsp;void&nbsp;__clone()</span></div></li>
<li><div class="src-line"><a name="a410"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#</span></div></li>
<li><div class="src-line"><a name="a411"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Clone&nbsp;properties.</span></div></li>
<li><div class="src-line"><a name="a412"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a413"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Buan/ModelCriteria.html#method__clone">__clone</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a414"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$whereGroup">whereGroup</a>&nbsp;=&nbsp;<span class="src-key">clone&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$whereGroup">whereGroup</a><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a415"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$havingGroup">havingGroup</a>&nbsp;=&nbsp;<span class="src-key">clone&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Buan/ModelCriteria.html#var$havingGroup">havingGroup</a><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a416"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a417"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a418"></a><span class="src-php">?&gt;</span></div></li>
</ol>
</span></div>
        <div class="credit">
		    <hr class="separator" />
		    Documentation generated on Tue, 04 Aug 2009 19:59:03 +0100 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>